home *** CD-ROM | disk | FTP | other *** search
- property ioFieldList, iFieldFocus, ioFIeldFocus, iCurrentMotionStyleIndex, iCurrentVisualStyleIndex, ikMotionScrollingUp, ikMotionIndividual, iFirstTime, iSaveSeconds, iSaveFPS, iSaveDelayEnter, iSaveDelayHold, iSaveMark, iSaveCycles
-
- on birth me
- global goCreditsText, goSeconds, goFPS, goDelayEnter, goDelayHold
- set ioFieldList to [goCreditsText, goSeconds, goFPS, goDelayEnter, goDelayHold]
- set ikMotionScrollingUp to 1
- set ikMotionIndividual to 2
- set iCurrentMotionStyleIndex to ikMotionScrollingUp
- set iCurrentVisualStyleIndex to 1
- set iFieldFocus to 1
- set iFirstTime to 1
- return me
- end
-
- on mInit me
- global goSeconds, goFPS, goDelayEnter, goDelayHold, goCredits, goMarkFrame, goVisualStyles, goMotionStyles, goScoreMgr, goAnimateTitle
- mInit(goMarkFrame, 4)
- if iFirstTime then
- mSetValue(goSeconds, 5)
- mSetValue(goFPS, 5)
- mSetValue(goDelayEnter, 5)
- mSetValue(goDelayHold, 0)
- mSetValue(goMarkFrame, 1)
- set iFirstTime to 0
- else
- mSetValue(goSeconds, iSaveSeconds)
- mSetValue(goFPS, iSaveFPS)
- mSetValue(goDelayEnter, iSaveDelayEnter)
- mSetValue(goDelayHold, iSaveDelayHold)
- mSetValue(goMarkFrame, iSaveMark)
- end if
- set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
- set goMotionStyles to 0
- set goMotionStyles to birth(script "RadioButton", 26, 2, 0, iCurrentMotionStyleIndex)
- if the machineType < 256 then
- mInit(goVisualStyles, the number of member "CreditsVisualStylesMac", iCurrentVisualStyleIndex, 8, 19)
- else
- mInit(goVisualStyles, the number of member "CreditsVisualStylesPC", iCurrentVisualStyleIndex, 8, 19)
- end if
- set the keyDownScript to "mCheckKey(goCredits)"
- end
-
- on mSetFieldFocus me, oWhom
- set where to getOne(ioFieldList, oWhom)
- if where = 0 then
- alert("Internal error - mSetFieldFocus could not find object")
- return
- end if
- set iFieldFocus to where
- set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
- end
-
- on mCheckKey me
- if the key = TAB then
- set iFieldFocus to IncrMod(iFieldFocus, count(ioFieldList))
- set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
- pass()
- else
- if iFieldFocus = 1 then
- pass()
- else
- if (offset(the key, "0123456789") > 0) or (the key = BACKSPACE) then
- pass()
- else
- dontPassEvent()
- end if
- end if
- end if
- end
-
- on mSetNewMotionStyle me, theNewStyleIndex
- set iCurrentMotionStyleIndex to theNewStyleIndex
- end
-
- on mSetNewVisualStyle me, theNewStyleIndex
- set iCurrentVisualStyleIndex to theNewStyleIndex
- end
-
- on mValidate me
- set lastFieldOKFlag to mValidate(ioFIeldFocus)
- return lastFieldOKFlag
- end
-
- on mCheckFormat me
- set theText to field "CreditsText"
- set nLines to the number of lines in theText
- repeat with thisLine = 1 to nLines
- if offset(":", line thisLine of field "CreditsText") = 0 then
- alert("Line" && thisLine && "of the Credits text does not contain a colon.")
- return 0
- end if
- end repeat
- return 1
- end
-
- on mParseLine me, theLineToParse, theHeaderFont, theHeaderSize, theBodyFont, theBodySize
- global gCastNumTextAsBitmap
- set where to offset(":", theLineToParse)
- set theHeaderText to char 1 to where of theLineToParse
- set nChars to the number of chars in theLineToParse
- set theBodyText to char where + 1 to nChars of theLineToParse
- set castNumHeader to mModifyRichTextCM(goCastMgr, theHeaderText, theHeaderFont, theHeaderSize)
- if castNumHeader = 0 then
- return 0
- end if
- set the picture of member gCastNumTextAsBitmap to the picture of member castNumHeader
- set widthHeader to the width of member gCastNumTextAsBitmap
- set heightHeader to the height of member castNumHeader / the number of lines in the text of member castNumHeader
- set castNumHeaderTarget to mFindFreeCastRun(goCastMgr, 1, 1)
- copyToClipBoard(member castNumHeader)
- tell the stage
- pasteClipBoardInto(member castNumHeaderTarget)
- set the name of member castNumHeaderTarget to "RichText" && string(the ticks)
- end tell
- set castNumBody to mModifyRichTextCM(goCastMgr, theBodyText, theBodyFont, theBodySize)
- if castNumBody = 0 then
- return 0
- end if
- set the picture of member gCastNumTextAsBitmap to the picture of member castNumBody
- set widthBody to the width of member gCastNumTextAsBitmap
- set heightBody to the height of member castNumBody / the number of lines in the text of member castNumBody
- set castNumBodyTarget to mFindFreeCastRun(goCastMgr, 1, 1)
- copyToClipBoard(member castNumBody)
- tell the stage
- pasteClipBoardInto(member castNumBodyTarget)
- set the name of member castNumBodyTarget to "RichText" && string(the ticks)
- end tell
- return [castNumHeaderTarget, castNumBodyTarget, widthHeader, heightHeader, widthBody, heightBody]
- end
-
- on mSplitAndCreate2 me, theTextToParse, theHeaderFont, theHeaderSize, theBodyFont, theBodySize
- global gCastNumTextAsBitmap
- set nLines to the number of lines in theTextToParse
- set theHeaderText to EMPTY
- set theBodyText to EMPTY
- repeat with thisLine = 1 to nLines
- set theLineToParse to line thisLine of theTextToParse
- set where to offset(":", theLineToParse)
- set theHeaderPart to char 1 to where of theLineToParse
- set nChars to the number of chars in theLineToParse
- set theBodyPart to char where + 1 to nChars of theLineToParse
- if thisLine > 1 then
- set theHeaderText to theHeaderText & RETURN
- set theBodyText to theBodyText & RETURN
- end if
- set theHeaderText to theHeaderText & theHeaderPart
- set theBodyText to theBodyText & theBodyPart
- end repeat
- set castNumHeader to mModifyRichTextCM(goCastMgr, theHeaderText, theHeaderFont, theHeaderSize)
- if castNumHeader = 0 then
- return 0
- end if
- set the picture of member gCastNumTextAsBitmap to the picture of member castNumHeader
- set widthHeader to the width of member gCastNumTextAsBitmap
- set heightHeader to the height of member castNumHeader
- set castNumHeaderTarget to mFindFreeCastRun(goCastMgr, 1, 1)
- copyToClipBoard(member castNumHeader)
- tell the stage
- pasteClipBoardInto(member castNumHeaderTarget)
- set the name of member castNumHeaderTarget to "RichText" && string(the ticks)
- end tell
- set castNumBody to mModifyRichTextCM(goCastMgr, theBodyText, theBodyFont, theBodySize)
- if castNumBody = 0 then
- return 0
- end if
- set the picture of member gCastNumTextAsBitmap to the picture of member castNumBody
- set widthBody to the width of member gCastNumTextAsBitmap
- set heightBody to the height of member castNumBody
- set castNumBodyTarget to mFindFreeCastRun(goCastMgr, 1, 1)
- copyToClipBoard(member castNumBody)
- tell the stage
- pasteClipBoardInto(member castNumBodyTarget)
- set the name of member castNumBodyTarget to "RichText" && string(the ticks)
- end tell
- return [castNumHeaderTarget, castNumBodyTarget, widthHeader, heightHeader, widthBody, heightBody]
- end
-
- on mCreate me
- global goMarkFrame, goMotionStyles, goVisualStyles, goScoreMgr, goCastMgr, gDevelopmentFlag, gCastNumTextAsBitmap, goPlatform
- if not mValidate(me) then
- return
- end if
- if the last char in field "CreditsText" = RETURN then
- delete char -30000 of field "CreditsText"
- end if
- if field "CreditsText" = EMPTY then
- alert("Please enter some text for the Credit.")
- return
- end if
- if not mCheckFormat(me) then
- return
- end if
- tell the stage
- set theStageFrame to the frame
- end tell
- set castNumVisualStyle to mGetCastNum(goVisualStyles, iCurrentVisualStyleIndex)
- set theVisualStyleName to the name of cast castNumVisualStyle
- set theHeaderFont to word 2 of theVisualStyleName
- set theHeaderSize to word 3 of theVisualStyleName
- set theBodyFont to word 4 of theVisualStyleName
- set theBodySize to word 5 of theVisualStyleName
- set theSeconds to integer(field "Seconds")
- set fps to integer(field "FPS")
- set nFrames to integer(theSeconds * fps)
- set delayEnter to integer(field "DelayEnter")
- set delayHold to integer(field "DelayHold")
- set markFirst to mGetValue(goMarkFrame)
- set theForeColor to 255
- set theBackColor to 0
- if iCurrentMotionStyleIndex = ikMotionScrollingUp then
- set thisList to mSplitAndCreate2(me, field "CreditsText", theHeaderFont, theHeaderSize, theBodyFont, theBodySize)
- if thisList = 0 then
- return
- end if
- set castNumHeader to getAt(thisList, 1)
- set castNumBody to getAt(thisList, 2)
- set theWidthHeader to getAt(thisList, 3)
- set theHeightHeader to getAt(thisList, 4)
- set theWidthBody to getAt(thisList, 5)
- set theHeightBody to getAt(thisList, 6)
- if delayEnter > 0 then
- set nTotalFrames to nFrames + 1
- else
- set nTotalFrames to nFrames
- end if
- if not mInit(goScoreMgr, nTotalFrames, 2) then
- return
- end if
- set chHeader to mGetNextSelectedChannel(goScoreMgr)
- set chBody to mGetNextSelectedChannel(goScoreMgr)
- set theFrameNum to mGetStartFrame(goScoreMgr)
- set frameList to []
- repeat with i = theFrameNum to theFrameNum + nTotalFrames - 1
- add(frameList, [i])
- end repeat
- if markFirst then
- set theLabel to "AW.Credit." & word 1 of the text of field "CreditsText" & " " & mGetGeneratedScoreSelection(goScoreMgr)
- set firstFrame to getAt(frameList, 1)
- add(firstFrame, [#label, theLabel])
- setAt(frameList, 1, firstFrame)
- end if
- set relFrameCount to 1
- set firstFrame to getAt(frameList, relFrameCount)
- set secondFrame to getAt(frameList, relFrameCount + 1)
- if delayEnter > 0 then
- add(firstFrame, [#tempo, -delayEnter])
- add(secondFrame, [#tempo, fps])
- setAt(frameList, relFrameCount, firstFrame)
- setAt(frameList, relFrameCount + 1, secondFrame)
- set theFrameNum to theFrameNum + 1
- set relFrameCount to relFrameCount + 1
- else
- add(firstFrame, [#tempo, fps])
- add(secondFrame, [#tempo, 0])
- setAt(frameList, relFrameCount, firstFrame)
- setAt(frameList, relFrameCount + 1, secondFrame)
- end if
- set theStageWidth to mGetStageWidth(goScoreMgr)
- set theStageHeight to mGetStageHeight(goScoreMgr)
- set totalTextWidth to theWidthHeader + theWidthBody
- set xLocHeader to integer((theStageWidth / 2) - (totalTextWidth / 2))
- set xLocBody to integer(xLocHeader + theWidthHeader)
- set maxHeight to max(theHeightHeader, theHeightBody)
- set yStart to theStageHeight - 10
- set yEnd to 0 - maxHeight - 10
- set yInc to float(yEnd - yStart) / float(nFrames)
- set yLoc to yStart
- repeat with thisFrame = 1 to nFrames
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#sprite, chHeader, castNumHeader, theForeColor, theBackColor, xLocHeader, yLoc, 0, 0])
- add(currentFrame, [#sprite, chBody, castNumBody, theForeColor, theBackColor, xLocBody, yLoc, 0, 0])
- setAt(frameList, relFrameCount, currentFrame)
- set theFrameNum to theFrameNum + 1
- set relFrameCount to relFrameCount + 1
- set yLoc to integer(yLoc + yInc)
- end repeat
- else
- set nSourceLines to the number of lines in field "CreditsText"
- set nFrames to (delayEnter + 1) * nSourceLines
- if not mInit(goScoreMgr, nFrames, 2) then
- return
- end if
- set maxHeaderWidth to 0
- set maxBodyWidth to 0
- set castNumList to []
- repeat with thisLine = 1 to nSourceLines
- set thisList to mParseLine(me, line thisLine of field "CreditsText", theHeaderFont, theHeaderSize, theBodyFont, theBodySize)
- if thisList = 0 then
- return
- end if
- set thisCastNumHeaderTarget to getAt(thisList, 1)
- set thisCastNumBodyTarget to getAt(thisList, 2)
- set thisWidthHeader to getAt(thisList, 3)
- set thisHeightHeader to getAt(thisList, 4)
- set thisWidthBody to getAt(thisList, 5)
- set thisHeightBody to getAt(thisList, 6)
- if thisWidthHeader > maxHeaderWidth then
- set maxHeaderWidth to thisWidthHeader
- end if
- if thisWidthBody > maxBodyWidth then
- set maxBodyWidth to thisWidthBody
- end if
- add(castNumList, [thisCastNumHeaderTarget, thisCastNumBodyTarget])
- end repeat
- set theForeColor to 255
- set theBackColor to 0
- set chHeader to mGetNextSelectedChannel(goScoreMgr)
- set chBody to mGetNextSelectedChannel(goScoreMgr)
- set theFrameNum to mGetStartFrame(goScoreMgr)
- set frameList to []
- repeat with i = theFrameNum to theFrameNum + nFrames - 1
- add(frameList, [i])
- end repeat
- if markFirst then
- set theLabel to "AW.Credit." & word 1 of the text of field "CreditsText" & " " & mGetGeneratedScoreSelection(goScoreMgr)
- set firstFrame to getAt(frameList, 1)
- add(firstFrame, [#label, theLabel])
- setAt(frameList, 1, firstFrame)
- end if
- set relFrameCount to 1
- set theStageWidth to mGetStageWidth(goScoreMgr)
- set theStageHeight to mGetStageHeight(goScoreMgr)
- set totalTextWidth to maxHeaderWidth + maxBodyWidth
- set xLocHeader to integer((theStageWidth / 2) - (totalTextWidth / 2))
- set xLocBody to integer(xLocHeader + maxHeaderWidth)
- set yLoc to integer(theStageHeight / 2)
- repeat with thisLine = 1 to nSourceLines
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#tempo, fps])
- setAt(frameList, relFrameCount, currentFrame)
- set thisCastNumList to getAt(castNumList, thisLine)
- set castNumHeader to getAt(thisCastNumList, 1)
- set castNumBody to getAt(thisCastNumList, 2)
- repeat with thisFrame = 1 to delayEnter
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#sprite, chHeader, castNumHeader, theForeColor, theBackColor, xLocHeader, yLoc, 0, 0])
- add(currentFrame, [#sprite, chBody, castNumBody, theForeColor, theBackColor, xLocBody, yLoc, 0, 0])
- setAt(frameList, relFrameCount, currentFrame)
- set theFrameNum to theFrameNum + 1
- set relFrameCount to relFrameCount + 1
- end repeat
- if delayHold > 0 then
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#tempo, delayHold])
- add(currentFrame, [#sprite, chHeader, castNumHeader, theForeColor, theBackColor, xLocHeader, yLoc, 0, 0])
- add(currentFrame, [#sprite, chBody, castNumBody, theForeColor, theBackColor, xLocBody, yLoc, 0, 0])
- setAt(frameList, relFrameCount, currentFrame)
- set relFrameCount to relFrameCount + 1
- set theFrameNum to theFrameNum + 1
- end if
- end repeat
- end if
- mWriteFrame(goScoreMgr, frameList)
- set labelName to "Credits" & goPlatform
- go(label(labelName) + 2)
- if not gDevelopmentFlag then
- tell the stage
- go(theStageFrame)
- end tell
- end if
- mClean(goScoreMgr)
- end
-
- on mCleanUp me
- global goMotionStyles, goSeconds, goFPS, goDelayEnter, goDelayHold, goMarkFrame
- mCleanUp(goMotionStyles)
- set iSaveSeconds to mGetValue(goSeconds)
- set iSaveFPS to mGetValue(goFPS)
- set iSaveDelayEnter to mGetValue(goDelayEnter)
- set iSaveDelayHold to mGetValue(goDelayHold)
- set iSaveMark to mGetValue(goMarkFrame)
- mCleanUp(goMarkFrame)
- end
-